/*
 * OrdenPlatillo.java
 *
 * Created on 16 de octubre de 2007, 06:07 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package data;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Entity class OrdenPlatillo
 * 
 * @author Fanny Paola  Vadillo Herrera
 * @author Luis Manuel Pineda Llano
 */
@Entity
@Table(name = "orden_platillo")
@NamedQueries( {
        @NamedQuery(name = "OrdenPlatillo.findByIdOrden", query = "SELECT o FROM OrdenPlatillo o WHERE o.ordenPlatilloPK.idOrden = :idOrden"),
        @NamedQuery(name = "OrdenPlatillo.findByIdPlatillo", query = "SELECT o FROM OrdenPlatillo o WHERE o.ordenPlatilloPK.idPlatillo = :idPlatillo"),
        @NamedQuery(name = "OrdenPlatillo.findByEstado", query = "SELECT o FROM OrdenPlatillo o WHERE o.estado = :estado"),
        @NamedQuery(name = "OrdenPlatillo.findByHoraEntrega", query = "SELECT o FROM OrdenPlatillo o WHERE o.horaEntrega = :horaEntrega"),
        @NamedQuery(name = "OrdenPlatillo.findByComentario", query = "SELECT o FROM OrdenPlatillo o WHERE o.comentario = :comentario"),
        @NamedQuery(name = "OrdenPlatillo.findForCocina", query = "SELECT o FROM OrdenPlatillo o, Orden ord WHERE o.ordenPlatilloPK.idOrden = ord.id AND o.estado <> 'Cancelado' AND o.estado <> 'Entregado' AND ord.fecha = :fecha"),
        @NamedQuery(name = "OrdenPlatillo.findForEstado", query = "SELECT o FROM OrdenPlatillo o WHERE o.ordenPlatilloPK.idOrden = :idOrden AND o.ordenPlatilloPK.idPlatillo = :idPlatillo"),
        @NamedQuery(name = "OrdenPlatillo.findForNota", query = "SELECT o FROM OrdenPlatillo o WHERE o.ordenPlatilloPK.idOrden = :idOrden AND o.estado = 'Entregado'")
    })
public class OrdenPlatillo implements Serializable {

    /**
     * EmbeddedId primary key field
     */
    @EmbeddedId
    protected OrdenPlatilloPK ordenPlatilloPK;

    @Column(name = "estado", nullable = false)
    private String estado;

    @Column(name = "horaEntrega")
    @Temporal(TemporalType.TIME)
    private Date horaEntrega;

    @Column(name = "comentario")
    private String comentario;

    @JoinColumn(name = "idOrden", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne
    private Orden orden;

    @JoinColumn(name = "idPlatillo", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne
    private Platillo platillo;
    
    /** Creates a new instance of OrdenPlatillo */
    public OrdenPlatillo() {
    }

    /**
     * Creates a new instance of OrdenPlatillo with the specified values.
     * @param ordenPlatilloPK the ordenPlatilloPK of the OrdenPlatillo
     */
    public OrdenPlatillo(OrdenPlatilloPK ordenPlatilloPK) {
        this.ordenPlatilloPK = ordenPlatilloPK;
    }

    /**
     * Creates a new instance of OrdenPlatillo with the specified values.
     * @param ordenPlatilloPK the ordenPlatilloPK of the OrdenPlatillo
     * @param estado the estado of the OrdenPlatillo
     */
    public OrdenPlatillo(OrdenPlatilloPK ordenPlatilloPK, String estado) {
        this.ordenPlatilloPK = ordenPlatilloPK;
        this.estado = estado;
    }

    /**
     * Creates a new instance of OrdenPlatilloPK with the specified values.
     * @param idPlatillo the idPlatillo of the OrdenPlatilloPK
     * @param idOrden the idOrden of the OrdenPlatilloPK
     */
    public OrdenPlatillo(int idPlatillo, int idOrden) {
        this.ordenPlatilloPK = new OrdenPlatilloPK(idPlatillo, idOrden);
    }

    /**
     * Gets the ordenPlatilloPK of this OrdenPlatillo.
     * @return the ordenPlatilloPK
     */
    public OrdenPlatilloPK getOrdenPlatilloPK() {
        return this.ordenPlatilloPK;
    }

    /**
     * Sets the ordenPlatilloPK of this OrdenPlatillo to the specified value.
     * @param ordenPlatilloPK the new ordenPlatilloPK
     */
    public void setOrdenPlatilloPK(OrdenPlatilloPK ordenPlatilloPK) {
        this.ordenPlatilloPK = ordenPlatilloPK;
    }

    /**
     * Gets the estado of this OrdenPlatillo.
     * @return the estado
     */
    public String getEstado() {
        return this.estado;
    }

    /**
     * Sets the estado of this OrdenPlatillo to the specified value.
     * @param estado the new estado
     */
    public void setEstado(String estado) {
        this.estado = estado;
    }

    /**
     * Gets the horaEntrega of this OrdenPlatillo.
     * @return the horaEntrega
     */
    public Date getHoraEntrega() {
        return this.horaEntrega;
    }

    /**
     * Sets the horaEntrega of this OrdenPlatillo to the specified value.
     * @param horaEntrega the new horaEntrega
     */
    public void setHoraEntrega(Date horaEntrega) {
        this.horaEntrega = horaEntrega;
    }

    /**
     * Gets the comentario of this OrdenPlatillo.
     * @return the comentario
     */
    public String getComentario() {
        return this.comentario;
    }

    /**
     * Sets the comentario of this OrdenPlatillo to the specified value.
     * @param comentario the new comentario
     */
    public void setComentario(String comentario) {
        this.comentario = comentario;
    }

    /**
     * Gets the orden of this OrdenPlatillo.
     * @return the orden
     */
    public Orden getOrden() {
        return this.orden;
    }

    /**
     * Sets the orden of this OrdenPlatillo to the specified value.
     * @param orden the new orden
     */
    public void setOrden(Orden orden) {
        this.orden = orden;
    }

    /**
     * Gets the platillo of this OrdenPlatillo.
     * @return the platillo
     */
    public Platillo getPlatillo() {
        return this.platillo;
    }

    /**
     * Sets the platillo of this OrdenPlatillo to the specified value.
     * @param platillo the new platillo
     */
    public void setPlatillo(Platillo platillo) {
        this.platillo = platillo;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.ordenPlatilloPK != null ? this.ordenPlatilloPK.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this OrdenPlatillo.  The result is 
     * <code>true</code> if and only if the argument is not null and is a OrdenPlatillo object that 
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdenPlatillo)) {
            return false;
        }
        OrdenPlatillo other = (OrdenPlatillo)object;
        if (this.ordenPlatilloPK != other.ordenPlatilloPK && (this.ordenPlatilloPK == null || !this.ordenPlatilloPK.equals(other.ordenPlatilloPK))) return false;
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "data.OrdenPlatillo[ordenPlatilloPKIdOrden=" + ordenPlatilloPK.getIdOrden() + "]";
    }
    
}